﻿package frEngine.shader.filters.fragmentFilters.extra
{
    import baseEngine.core.*;
    import frEngine.manager.*;
    import frEngine.shader.*;
    import frEngine.shader.filters.*;
    import frEngine.shader.filters.fragmentFilters.*;

    public class PixsMaskFilter extends FragmentFilter
    {
        public var texture:Texture3D;

        public function PixsMaskFilter(param1:Texture3D)
        {
            super([param1]);
            this.texture = param1;
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            param1.getParamByName("{texture1}", false).value = this.texture;
            return;
        }// end function

        override public function get programeId() : String
        {
            if (this.texture && (this.texture.loadedAndUpload || this.texture.targetInfo))
            {
                return "PixsMaskFilter:" + FilterBase.ATLFormat[this.texture.format] + ",mip:" + this.texture.mipMode;
            }
            return null;
        }// end function

        override public function clone() : FilterBase
        {
            var _loc_1:* = Resource3dManager.instance.getTexture3d(this.texture.request, this.texture.mipMode);
            var _loc_2:* = new PixsMaskFilter(_loc_1);
            return _loc_2;
        }// end function

        override public function createVertexCode(param1:Program3dRegisterInstance, param2:int) : String
        {
            var _loc_3:* = new Array();
            _loc_3.push(new ToBuilderInfo("va0", FilterName.UV, false, 2));
            _loc_3.push(new ToBuilderInfo("vf0", FilterName.V_UvOriginalPos, false, 1));
            var _loc_4:String = "mov           vf0         \t va0        \t\t\t\t\n";
            _loc_4 = param1.toBuild(_loc_4, _loc_3);
            return _loc_4;
        }// end function

        override public function createFragmentUvCoord(param1:Program3dRegisterInstance) : String
        {
            var _loc_2:* = new Array();
            var _loc_3:String = "";
            _loc_2.push(new ToBuilderInfo("ft0", FilterName.F_UVPostion, false, 1));
            var _loc_4:* = FilterName.V_UvOriginalPos;
            _loc_3 = _loc_3 + ("mov           ft0         \t " + _loc_4 + "        \t\t\t\t\n");
            _loc_3 = param1.toBuild(_loc_3, _loc_2);
            return _loc_3;
        }// end function

        override public function createFragmentColor(param1:Program3dRegisterInstance, param2:Boolean) : String
        {
            var _loc_3:* = new Array();
            _loc_3.push(new ToBuilderInfo("fs0", "{texture1}", false, 1, this.texture));
            var _loc_4:String = "";
            _loc_4 = _loc_4 + ("tex        ft0          {F_UVPostion}.xy    " + getSmapleString("fs0", this.texture.format, param2, this.texture.mipMode) + "\t\n");
            _loc_4 = _loc_4 + "sub\t\t\tft0.x\t   \t\t\t{fcConst1}.w         \t\tft0.x\t\t\t\t\n";
            _loc_4 = _loc_4 + "kill\t\t\tft0.x\t   \t\t\n";
            _loc_4 = _loc_4 + "mov\t\t\t{output}\t   \t\t{fcConst1}.x\n";
            _loc_4 = param1.toBuild(_loc_4, _loc_3);
            return _loc_4;
        }// end function

    }
}
